package com.pig4cloud.pig.item.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pig4cloud.pig.item.api.pojo.Category;
import com.pig4cloud.pig.item.api.pojo.Taskmark;
import com.pig4cloud.pig.item.mapper.CategoryMapper;
import com.pig4cloud.pig.item.mapper.TaskmarkMapper;
import com.pig4cloud.pig.item.service.TaskmsrkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by caoxuel on 2020/10/14 16:03
 */
@Service
public class TaskmsrkServiceImpl extends ServiceImpl<TaskmarkMapper, Taskmark> implements TaskmsrkService {

    @Autowired
    private TaskmarkMapper taskmarkMapper;

    @Autowired
    private CategoryMapper categoryMapper;

    @Override
    public List<Taskmark> getTaskmark(String categoryName){
        QueryWrapper<Category> queryId = new QueryWrapper<>();
        queryId.eq("category_name", categoryName);

        Category categories1 = categoryMapper.selectOne(queryId);
        QueryWrapper<Taskmark> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("category_id", categories1.getCategoryId());
        List<Taskmark> categories = taskmarkMapper.selectList(queryWrapper);

        return categories;
    }
}
